<template>
	<view class="ba-container ">
		<view class="doctor-team">
			<view style="margin-right: 20rpx;">
				<image :src="teamDetailsData.avatar" style="width: 220rpx; height: 220rpx;"></image>
			</view>
			<view>
				<view class="">{{teamDetailsData?.name}}</view>
					<navigator :url="`/nearbyinstitutions/pages/Institutionslisthome/Institutionslisthome?_id=${teamDetailsData.organizationId?._id}`">
					<view style="display: flex; align-items: center;
						">
						<span style="font-size: 12px;color: #999999;line-height: 27px; margin-right: 10rpx;
								white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
								display: inline-block; width: 400rpx;white-space: nowrap; overflow: hidden; 
								text-overflow: ellipsis;">
							所属机构: {{teamDetailsData.organizationId?.name}}
						</span>
						<image src="/static/right.png" style="width: 14rpx;height:20rpx ;"></image>
					</view>
				</navigator>

				<view style="font-size: 12px;color: #999999;line-height: 27px;">
					签约人数：<span style="color: #2984F8;">{{teamDetailsData.signNumber}}</span>
				</view>
				<view style="display: flex; align-items: center;">
					<template v-for="(temp,index) in 5">
						<image src="/static/sc.png" style="width: 28rpx;
							 height: 30rpx;" v-if="index<(teamDetailsData.rate-1)">
						</image>
						<image src="/static/kongsc.png" style="width: 28rpx; height: 30rpx;" v-else></image>
					</template>
					<span style="font-size: 12px;color: #FDDB78; line-height: 30rpx;
						margin-left: 20rpx;margin-top: 3px;">{{ teamDetailsData.rate }}.0</span>
				</view>
			</view>

		</view>
		<view style="margin-bottom: 40rpx;">
			<template v-for="item in teamDetailsData.tagIds">
				<span style="height: 48rpx;background-color: rgba(41, 132, 248, 0.2);
					    border: none;font-size: 12px;color: #2984F8; text-align: center;
						line-height: 48rpx; padding: 10rpx 20rpx; border-radius: 5px;margin-right: 20rpx;">
					{{item?.name}}</span>
			</template>

		</view>
		<view class="">
			<span class="item-title">团队医生</span>
		</view>
		<template v-for="item in teamDetailsData.memberIds">
			<navigator :url="`/doctormanage/pages/doctorInfo/doctorInfo?_id=${item._id}`">
				<view class="doctor-info">
					<view style="margin-right: 20rpx;">
						<image :src="item.avatar" style="width: 160rpx; height: 160rpx;"></image>
					</view>
					<view>
						<view class="">
							<span>{{item.name}}</span>
							<span style="font-size: 12px;color: #999999;margin-left: 10rpx;
							white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
							 width: 180rpx;display: inline-block;
							">{{item.roleId.name}}</span>
						</view>
						<view style="font-size: 12px;color: #999999;line-height: 27px;">
							签约人数：<span style="color: #2984F8;">{{item.signNumber}}</span>
						</view>
					</view>
					<view class="">
						<button style="background-color: #2984F8;color: #ffffff;width: 126rpx; 
						height: 64rpx; line-height: 64rpx;">签约</button>
					</view>
				</view>
			</navigator>
		</template>
		<view class="">
			<span class="item-title">服务包</span>
		</view>
		<template v-for="item in teamDetailsData.servicePackIds">
			<navigator :url="`/servePackage/pages/serveDetail/serveDetail?_id=${item._id}`">
				<view class="service-pack">
					<view style="margin-right: 20rpx;">
						<image :src="item.image" style="width: 160rpx; height: 160rpx;"></image>
					</view>
					<view style="flex: 1;">
						<view style="display: flex; justify-content: space-between;">
							<span>{{item?.name}}</span>
							<span style="color: #FA746B;line-height: 28px; font-size: 18px;">￥{{item.price}}</span>
						</view>
						<view class="">
							<template v-for="temp in item.tagIds">
								<span style="height: 48rpx;background-color: rgba(41, 132, 248, 0.2);
									    border: none;font-size: 12px;color: #2984F8; text-align: center;
										line-height: 48rpx; padding: 10rpx 20rpx; border-radius: 5px;margin-right: 20rpx;">
									{{temp?.name}}</span>
							</template>
						</view>
					</view>
					
				</view>
			</navigator>
		</template>
		
	</view>
	<navigator url="/sing/pages/applysing/applysing">
		<view class="application-btn">
			<button style="width: 670rpx; height: 88rpx;background-color: #2984F8;color: #ffffff;">申请签约</button>
		</view>
	</navigator>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		ref
	} from 'vue';
	import {
		getTeamDetailByIdApi
	} from '../../../api/Institutionslist';


	const teamDetailsData = ref({});


	onLoad((options) => {
		getTeamDetailById(options)
	})


	function getTeamDetailById(data) {
		getTeamDetailByIdApi(data).then(res => {
			if (res.code == 200) {
				teamDetailsData.value = res.data
			}
		})
	}
</script>

<style scoped lang="scss">
	.ba-container {
		min-height: 100vh;
		background-color: aliceblue;
		display: flex;
		flex-direction: column;
		padding: 40rpx;
	}

	.doctor-team {
		width: 590rpx;
		border-radius: 22rpx;
		margin: 20rpx 0;
		display: flex;
		align-items: center;
	}

	.item-title {
		font-weight: 500;
		font-size: 18px;
	}

	.doctor-info {
		width: 630rpx;
		height: 200rpx;
		background-color: #ffffff;
		border-radius: 22rpx;
		margin: 20rpx 0;
		display: flex;
		align-items: center;
		justify-content: space-around;
		padding: 0 20rpx;
	}
	.service-pack{
		width: 630rpx;
		height: 200rpx;
		background-color: #ffffff;
		border-radius: 22rpx;
		margin: 20rpx 0;
		display: flex;
		align-items: center;
		padding: 0 20rpx;
	}
	.application-btn{
		background-color: #ffffff;
		width: 100%;
		height: 160rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		position: fixed;
		top: 90vh;
		left: 0;
	}
</style>